package com.yang.dao.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.math.BigDecimal;
import java.util.List;

@Data
@Accessors(chain = true)
@Document(collection = "skus")
// 当属性为默认值时，不序列化
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
@NoArgsConstructor
@AllArgsConstructor
@Builder
@TableName("category")
public class SkusDO {

    /**
     * MongoDB中sku表的id
     */
    @Id
    @JsonIgnore
    @Schema(description = "id")
    @Field("_id")
    private Long id;

    /**
     * sku id
     */
    private Long skuId;

    /**
     * 商品id
     */
    private Long commodityId;

    /**
     * sku价格
     */
    private BigDecimal price;

    /**
     * sku库存
     */
    private Integer stock;

    /**
     * sku规格列表，包含规格名称和规格值
     */
    public List<SpecsDO> specs;

    @Override
    public String toString() {
        return "SkusDO{" +
                "skuId=" + skuId +
                ", commodityId=" + commodityId +
                ", specs=" + specs +
                ", price=" + price +
                ", stock=" + stock +
                '}' + "\n";
    }
}
